/*
 * Daniel R Padilla
 *
 * Copyright (c) 2008, Daniel R Padilla
 *
 * This copyrighted material is made available to anyone wishing to use, modify,
 * copy, or redistribute it subject to the terms and conditions of the GNU
 * Lesser General Public License, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this distribution; if not, write to:
 * Free Software Foundation, Inc.
 * 51 Franklin Street, Fifth Floor
 * Boston, MA  02110-1301  USA
 */
package org.databasefacade.select;

import org.databasefacade.table.Table;
import org.databasefacade.table.column.Column;


/**
 * All the operators in this class have
 * ansiSQL standard definitions so the
 * class is not declared as abstract
 * because ansiSQL-92 is sufficient.
 * 
 * Critical: 
 * 
 * The class needs to force the use of the
 * Table and Column classes and avoid the 
 * use of strings so that non-ansiSQL does
 * not find it way into the library.
 * 
 */
public class Arithmetic {
    private String operationSQL = null;
    
    /*
     * Add Methods
     */
    public void add(Table table1, Column field1, Table table2, Column field2) {
        operationSQL = Operator.assign(table1, field1, table2, field2,
                Operator.ADD);
    }
    
    public void add(Column field1, Column field2) {
        operationSQL = Operator.assign(field1, field2, Operator.ADD);
    }

    public void add(Table table1, Column field1, Object value) {
        operationSQL = Operator.assign(table1, field1, value, Operator.ADD);
    }
    
    public void add(Column field, Object value) {
        operationSQL = Operator.assign(field, value, Operator.ADD);
    }


    public void add(Table table1, Column field1, Operator innerOperator) {
        operationSQL = Operator.assign(table1, field1, innerOperator,
                Operator.ADD);
    }

    public void add(Column field, Operator innerOperator) {
        operationSQL = Operator.assign(field, innerOperator,
                Operator.ADD);
    }
    
    /*
     * Subtract Methods
     */
    public void subtract(Table table1, Column field1, Table table2, Column field2) {
        operationSQL = Operator.assign(table1, field1, table2, field2,
                Operator.SUBTRACT);
    }
    
    public void subtract(Column field1, Column field2) {
        operationSQL = Operator.assign(field1, field2, Operator.SUBTRACT);
    }

    public void subtract(Table table1, Column field1, Object value) {
        operationSQL = Operator.assign(table1, field1, value, Operator.SUBTRACT);
    }
    
    public void subtract(Column field, Object value) {
        operationSQL = Operator.assign(field, value, Operator.SUBTRACT);
    }

    public void subtract(Table table1, Column field1, Operator innerOperator) {
        operationSQL = Operator.assign(table1, field1, innerOperator,
        		Operator.SUBTRACT);
    }

    public void subtract(Column field, Operator innerOperator) {
        operationSQL = Operator.assign(field, innerOperator,
        		Operator.SUBTRACT);
    }
    
    /*
     * Multiply Methods
     */
    public void multiply(Table table1, Column field1, Table table2, Column field2) {
        operationSQL = Operator.assign(table1, field1, table2, field2,
        		Operator.MULTIPLY);
    }
    
    public void multiply(Column field1, Column field2) {
        operationSQL = Operator.assign(field1, field2, Operator.MULTIPLY);
    }

    public void multiply(Table table1, Column field1, Object value) {
        operationSQL = Operator.assign(table1, field1, value, Operator.MULTIPLY);
    }
    
    public void multiply(Column field, Object value) {
        operationSQL = Operator.assign(field, value, Operator.MULTIPLY);
    }

    public void multiply(Table table1, Column field1, Operator innerOperator) {
        operationSQL = Operator.assign(table1, field1, innerOperator,
        		Operator.DIVIDE);
    }

    public void multiply(Column field, Operator innerOperator) {
        operationSQL = Operator.assign(field, innerOperator,
        		Operator.MULTIPLY);
    }
    
    /*
     * Divide Methods
     */
    public void divide(Table table1, Column field1, Table table2, Column field2) {
        operationSQL = Operator.assign(table1, field1, table2, field2,
        		Operator.DIVIDE);
    }
    
    public void divide(Column field1, Column field2) {
        operationSQL = Operator.assign(field1, field2, Operator.DIVIDE);
    }

    public void divide(Table table1, Column field1, Object value) {
        operationSQL = Operator.assign(table1, field1, value, Operator.DIVIDE);
    }
    
    public void divide(Column field, Object value) {
        operationSQL = Operator.assign(field, value, Operator.DIVIDE);
    }

    public void divide(Table table1, Column field1, Operator innerOperator) {
        operationSQL = Operator.assign(table1, field1, innerOperator,
        		Operator.DIVIDE);
    }

    public void divide(Column field, Operator innerOperator) {
        operationSQL = Operator.assign(field, innerOperator,
        		Operator.DIVIDE);
    }

    /*
     * Modulo Methods
     */
    public void modulo(Table table1, Column field1, Table table2, Column field2) {
        operationSQL = Operator.assign(table1, field1, table2, field2,
        		Operator.MODULO);
    }
    
    public void modulo(Column field1, Column field2) {
        operationSQL = Operator.assign(field1, field2, Operator.MODULO);
    }

    public void modulo(Table table1, Column field1, Object value) {
        operationSQL = Operator.assign(table1, field1, value, Operator.MODULO);
    }
    
    public void modulo(Column field, Object value) {
        operationSQL = Operator.assign(field, value, Operator.MODULO);
    }

    public void modulo(Table table1, Column field1, Operator innerOperator) {
        operationSQL = Operator.assign(table1, field1, innerOperator,
        		Operator.MODULO);
    }

    public void molulo(Column field, Operator innerOperator) {
        operationSQL = Operator.assign(field, innerOperator,
        		Operator.MODULO);
    }

		
    public String getSQL() {
        return operationSQL;
    }
}
